package com.kevin.ymqquan.adapter;

import java.util.List;

import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.kevin.ymqquan.R;
import com.kevin.ymqquan.bean.ClubConUser;

public class ClubConUserAdapter extends BaseAdapter {

	private List<ClubConUser> clubUserList;
	private LayoutInflater lf;

	public ClubConUserAdapter(Activity mContext, List<ClubConUser> clubUserList) {
		this.clubUserList = clubUserList;
		lf = (LayoutInflater) mContext
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return clubUserList.size();
	}

	@Override
	public Object getItem(int arg0) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public long getItemId(int arg0) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		ClubUserHolder holder = new ClubUserHolder();
		if (convertView == null) {
			convertView = lf.inflate(R.layout.list_clubconuser_item, parent,
					false);
			holder.tv_clubconuser_item_consume = (TextView) convertView
					.findViewById(R.id.tv_clubconuser_item_consume);
			holder.tv_clubconuser_item_yearcard = (TextView) convertView
					.findViewById(R.id.tv_clubconuser_item_yearcard);
			holder.tv_clubconuser_item_yeartimescard = (TextView) convertView
					.findViewById(R.id.tv_clubconuser_item_yeartimescard);
			holder.tv_clubconuser_item_balancecard = (TextView) convertView
					.findViewById(R.id.tv_clubconuser_item_balancecard);
			holder.tv_clubconuser_item_username = (TextView) convertView
					.findViewById(R.id.tv_clubconuser_item_username);
			convertView.setTag(holder);
		} else {
			holder = (ClubUserHolder) convertView.getTag();
		}

		holder.tv_clubconuser_item_consume.setText("金额:"+clubUserList.get(position)
				.getConsume()+"");
		holder.tv_clubconuser_item_yearcard.setText("限时卡:"+clubUserList.get(position)
				.getYearcard());
		holder.tv_clubconuser_item_yeartimescard.setText("限时限次卡:"+clubUserList.get(position)
				.getYeartimescard());
		holder.tv_clubconuser_item_balancecard.setText("预存卡:"+clubUserList.get(position)
				.getBalancecard());
		holder.tv_clubconuser_item_username.setText(clubUserList.get(position)
				.getUserName());

		return convertView;
		
	}

	/**
	 * 自定义控件集合
	 */
	public static class ClubUserHolder {
		// 消费金额
		public TextView tv_clubconuser_item_consume;
		// 限时卡
		public TextView tv_clubconuser_item_yearcard;
		// 限次卡
		public TextView tv_clubconuser_item_yeartimescard;
		// 预存卡
		public TextView tv_clubconuser_item_balancecard;
		// 用户名
		public TextView tv_clubconuser_item_username;
	}

}
